﻿namespace MultipleMonitorVideo.ViewModels
{
    using System;
    using System.Windows.Input;

    public class VideoViewModel : ViewModel
    {
        private Uri fileName;
        private bool isVideoPlaying;
        
        public VideoViewModel()
        {
        }

        public Uri FileName
        {
            get
            {
                return this.fileName;
            }

            set
            {
                if (this.fileName != value)
                {
                    this.fileName = value;
                    this.NotifyOfPropertyChange();
                }
            }
        }

        public ICommand PlayVideoCommand
        {
            get;
            set;
        }

        public ICommand PauseVideoCommand
        {
            get;
            set;
        }

        public ICommand StopVideoCommand
        {
            get;
            set;
        }

        public bool IsVideoPlaying
        {
            get
            {
                return this.isVideoPlaying;
            }

            set
            {
                if (this.isVideoPlaying != value)
                {
                    this.isVideoPlaying = value;
                    this.NotifyOfPropertyChange();
                }
            }
        }

        public void PlayVideo()
        {
            this.IsVideoPlaying = true;

            if (this.PlayVideoCommand != null && this.PlayVideoCommand.CanExecute(null))
            {
                this.PlayVideoCommand.Execute(null);
            }
        }

        public void PauseVideo()
        {
            this.IsVideoPlaying = false;

            if (this.PauseVideoCommand != null && this.PauseVideoCommand.CanExecute(null))
            {
                this.PauseVideoCommand.Execute(null);
            }
        }

        public void StopVideo()
        {
            this.IsVideoPlaying = false;

            if (this.StopVideoCommand != null && this.StopVideoCommand.CanExecute(null))
            {
                this.StopVideoCommand.Execute(null);
            }
        }
    }
}
